package com.sskj.finance.presenter;

import com.lzy.okrx2.adapter.FlowableBody;
import com.sskj.common.base.HttpData;
import com.sskj.finance.bean.FinanRecordInfoBean;
import com.sskj.finance.http.HttpConfig;
import com.sskj.finance.ui.activity.MyOrderActivity;
import com.sskj.lib.bean.PageBean;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.lib.http.JsonConverter;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.Flowable;
import okhttp3.Response;


public class MyOrderActivityPresenter extends BasePresenter<MyOrderActivity> {


    /**
     * 我的订单
     *
     * @param p    页码，默认1
     * @param size 每页多少条，默认15
     * @return
     */
    public Flowable<List<FinanRecordInfoBean>> finanRecordInfo(String p, String size) {
        return httpService.finanRecordInfo(p, size)
                .converter(new JsonConverter<HttpData<PageBean<FinanRecordInfoBean>>>() {
                })
                .adapt(new FlowableBody<>())
                .map(pageBeanHttpData -> pageBeanHttpData.getData().getList())
                .onErrorReturnItem(new ArrayList<>());
    }
}
